#include "singletonmanager.h"

#include <boost/shared_ptr.hpp>

namespace raytracer {

boost::shared_ptr<SingletonManager> SingletonManager::__singleton_manager
   = boost::make_shared<SingletonManager>();

SingletonManager&
SingletonManager::instance() {
   return *__singleton_manager;
}

SingletonManager::SingletonManager()
{
   //caution first one is itself!
   this->push_back(__singleton_manager);
}

SingletonManager::~SingletonManager()
{
   iterator l_it( this->end() - 1);
   //caution first one is itself!
   for(; l_it != this->begin(); --l_it) {
      (*l_it)->break_bridge();
      l_it->reset();
   }
}

} //end of namespace
